<?php
namespace Home\Controller;
use Think\Controller;
class BaseController extends Controller {
	public function _initialize(){
		if($_SESSION){
			$Auth = new \Think\Auth();
  //需要验证的规则列表,支持逗号分隔的权限规则或索引数组
  $name = MODULE_NAME . '/' . CONTROLLER_NAME. '/' .ACTION_NAME;
  //当前用户id
  session_start();
		$uname=$_SESSION['username'];
		$m=M("Member");
		$res=$m->where("username='{$uname}'")->select();
		  $id=$res[0]["id"];	
  $uid = $id;//seesion
  if (!$Auth->check($name, $uid)) {
	  $this->assign("errormess",403);
	  $this->assign("errortitle","无权访问");
	  $this->assign("errormiao",5);
	  $this->error();
  }
	}else{
				header("Location:http:/Home/Index/login");
		}
}
}
?>